package com.inf.utils;


import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * Created by zhangbn on 2018/10/23.
 */
public class JedisUtil {

    private final static JedisPool POOL;

    static {
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxTotal(10);
        config.setMaxIdle(1);
        POOL = new JedisPool(config, "10.82.27.102", 6379, 3000, null, 2);
    }

    /**
     * 从池中获取链接
     */
    public static Jedis getJedis() {
        Jedis jedis = POOL.getResource();
        return jedis;
    }

    /**
     * 测试方法
     *
     * @param args
     */
    public static void main(String[] args) {
        boolean bool = JedisUtil.getJedis().getbit("180723_tag", 1);
        System.out.println(bool);
    }
}
